#!/bin/bash

. /usr/local/share/buildinfo/scripts/buildinfo_base.sh
[ -z $REAL_COMMAND ] && REAL_COMMAND=$(get_command wget)
if [ -z "$REAL_COMMAND" ]; then
    echo "The command wget does not exist." 1>&2
    exit 1
fi

# Retry if something super-weird has happened. Use --retry-connrefused option
# for wget.
# --retry-connrefused - Consider "connection refused" a transient error and try
# again. Normally wget/curl gives up on a URL when it is unable to connect to
# the site because failure to connect is taken as a sign that the server is not
# running at all and that retries would not help. This option is for mirroring
# unreliable sites whose servers tend to disappear for short periods of time.
REAL_COMMAND="$REAL_COMMAND --retry-connrefused"

if [ "$SKIP_BUILD_HOOK" == y ]; then
    $REAL_COMMAND "$@"
    exit $?
fi

REAL_COMMAND=$REAL_COMMAND download_packages "$@"
